package edu.njfu.homeork.test

import android.util.Log
import com.google.gson.Gson
import edu.njfu.homeork.model.ResultVO
import edu.njfu.homeork.utils.HttpUtil
import kotlinx.android.synthetic.main.activity_main.*
import okhttp3.Call
import okhttp3.Response
import java.io.IOException

fun main(){
    var userMap= HashMap<String,String>()
    userMap.put("username","zhangsan")
    userMap.put("password","123456")
//    Log.d("msg",loginAccount.text.toString()+"   "+loginPassword.text.toString()  )

    HttpUtil.sendOKHttpRequest("http://106.15.192.167:8080/userLogin",userMap,object :okhttp3.Callback{
        override fun onFailure(call: Call, e: IOException) {
            e.printStackTrace()
        }

        override fun onResponse(call: Call, response: Response) {
            val responseData=response.body?.string();
            val resultOK= Gson().fromJson(responseData, ResultVO::class.java)
//            println("msg  ","   "+resultOK.result  )
            if(resultOK.result.toString()=="ok"){
                println("登陆成功共")
            }else{
                println("登陆失败")

            }
        }
    })
}